import random
import string

# 随机生成字符串
def random_string(length=8):
    """Generates a random string of fixed length."""
    letters = string.ascii_lowercase + string.digits
    return ''.join(random.choice(letters) for _ in range(length))

# 随机生成密码
def random_password(length=10):
    """Generates a random password."""
    characters = string.ascii_letters + string.digits
    # Ensure password complexity if needed, e.g., at least one of each type
    password = ''.join(random.choice(characters) for i in range(length))
    return password

# 随机生成用户名
def random_username(prefix="", suffix="", length=8):
    """Generates a random username, potentially with prefix/suffix."""
    core = random_string(length)
    return f"{prefix}{core}{suffix}"
